/**
 *
 */
package com.angel.common.helpers;

import java.util.Locale;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/** The <code>LocaleHelper.class</code> helps you to manage some Locales functions.
 *  All its methods are statics.
 *
 * @author William
 * @version
 */
public class LocaleHelper {

	/** It is the logger for the class. */
	private static Logger logger = Logger.getLogger(LocaleHelper.class);

	private LocaleHelper(){
		super();
	}

	/** Return the singleton CollectionHelper's instance.
	 *  It needs the log's level to set.
	 *
	 * @param logLevel
	 * @return instance
	 */
	public static void setLogLevel(Level logLevel){
		logger.setLevel(logLevel);
	}

	public static Locale[] getAvailableLocales(){
		return Locale.getAvailableLocales();
	}

	public static String[] getISOLanguages(){
		return Locale.getISOLanguages();
	}

	public static Locale getLocaleFor(String languaje, String country){
		return new Locale(languaje, country);
	}

	public static Locale getLocaleFor(String languaje){
		return new Locale(languaje);
	}

	public static boolean isAvailableCoutnry(String countryName){
		boolean isAvailable = false;
		Locale[] locales = Locale.getAvailableLocales();
		for(int i = 0; !isAvailable && i < locales.length; i++){
			if(locales[i].getDisplayCountry().equals(countryName)){
				isAvailable = true;
			}
		}
		return isAvailable;
	}
}
